package com.edu.exam.entity.facility;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 楼宇状态枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum BuildingStatus implements BaseEnum {
    /**
     * 正常使用
     */
    NORMAL("正常使用"),

    /**
     * 维修中
     */
    MAINTENANCE("维修中"),

    /**
     * 停用
     */
    DISABLED("停用");

    private final String description;

    BuildingStatus(String description) {
        this.description = description;
    }

    @Override
    public String getCode() {
        return name();
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static BuildingStatus fromCode(String code) {
        for (BuildingStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown building status code: " + code);
    }

    public static BuildingStatus fromDescription(String description) {
        for (BuildingStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown building status description: " + description);
    }

    @Override
    public String toString() {
        return name() + " - " + description;
    }
}